#ifndef __EXCEPTIONS_INCLUDED
#define __EXCEPTIONS_INCLUDED


namespace Audio
{
	enum AudioErrorCode
	{	
		NoError = 0,
		APIFailed = 1,
		WrongArgument = 2,
		ArgumentOutOfRange = 3,
		NullPointer = 4,
		IndexOutOfRange = 5,
		OOM = 6,
		IOError = 7,
		CanNotOpenFile = 8,
		BadFormat = 9,
		EndOfFile = 10,
	};

	class ExceptionBase
	{
	public:
		ExceptionBase();
		ExceptionBase(const String& text);
		virtual const String& Text() const;
		virtual AudioErrorCode ErrorCode() const = 0;
	protected:
		String description;
	};

	class APIFailedException : public ExceptionBase
	{
	public:
		APIFailedException(const String& api);				
		virtual AudioErrorCode ErrorCode() const
		{
			return APIFailed;
		}		
	};
	class ArgumentException : public ExceptionBase
	{
	public:		
		ArgumentException();
		ArgumentException(const String& text);
		virtual AudioErrorCode ErrorCode() const
		{
			return WrongArgument;
		}
	};
	class ArgumentOutOfRangeException : public ArgumentException
	{
	public:
		ArgumentOutOfRangeException();
		virtual AudioErrorCode ErrorCode() const
		{
			return ArgumentOutOfRange;
		}
	};
	class NullPointerException : public ExceptionBase
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return NullPointer;
		}
	};
	class IndexOutOfRangeException : public ExceptionBase
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return IndexOutOfRange;
		}
	};
	class OutOfMemeryException : public ExceptionBase
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return OOM;
		}
	};
	class IOException : public ExceptionBase
	{
	public:
		IOException();
		IOException(const String& text);
		virtual AudioErrorCode ErrorCode() const
		{
			return IOError;
		}
	};
	class CanNotOpenFileException : public IOException 
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return CanNotOpenFile;
		}
	};
	class BadFormatException : public ExceptionBase 
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return BadFormat;
		}
	};
	class EndOfFileException : public IOException
	{
	public:
		virtual AudioErrorCode ErrorCode() const
		{
			return EndOfFile;
		}
	};

	class EndAudioThreadException
	{

	};
}

#endif